new Vue({
    el: '#app',
    data() {
        return {
            // 筛选条件
            selectedBatch: '',
            selectedStatus: '',
            schoolName: '',

            // 分页
            currentPage: 1,
            totalPages: 5,

            // 弹窗控制
            showRejectModal: false,
            rejectReason: '',
            currentSummaryId: null,

            // 总结数据
            summaries: [

            ]
        };
    },
    computed: {
        // 筛选后的总结列表
        filteredSummaries() {
            return this.summaries.filter(summary => {
                const matchesBatch = this.selectedBatch ? summary.batch.includes(this.selectedBatch) : true;
                const matchesStatus = this.selectedStatus ? summary.status === this.selectedStatus : true;
                const matchesSchool = this.schoolName ? summary.schoolName.includes(this.schoolName) : true;
                return matchesBatch && matchesStatus && matchesSchool;
            });
        }
    },
    methods: {
        // 获取状态显示文本
        getStatusText(status) {
            switch(status) {
                case 'pending': return '待审核';
                case 'approved': return '审核通过';
                case 'rejected': return '审核驳回';
                default: return '';
            }
        },

        // 获取状态样式类
        getStatusClass(status) {
            switch(status) {
                case 'pending': return 'status-pending';
                case 'approved': return 'status-approved';
                case 'rejected': return 'status-rejected';
                default: return '';
            }
        },

        // 搜索
        search() {
            this.currentPage = 1;
            console.log('搜索条件:', {
                batch: this.selectedBatch,
                status: this.selectedStatus,
                schoolName: this.schoolName
            });
        },

        // 重置筛选条件
        resetFilter() {
            this.selectedBatch = '';
            this.selectedStatus = '';
            this.schoolName = '';
            this.currentPage = 1;
        },

        // 查看总结详情
        viewSummary(id) {
            console.log('查看总结详情，ID:', id);
            // 实际应用中跳转到总结详情页
            // window.location.href = `summary-detail.html?id=${id}`;
            alert(`查看ID为 ${id} 的总结详情`);
        },

        // 通过审核
        approveSummary(id) {
            if(confirm('确定要通过该总结的审核吗？')) {
                const summary = this.summaries.find(item => item.id === id);
                if(summary) {
                    summary.status = 'approved';
                    alert('审核已通过');
                }
            }
        },

        // 驳回审核
        rejectSummary(id) {
            this.currentSummaryId = id;
            this.rejectReason = '';
            this.showRejectModal = true;
        },

        // 确认驳回
        confirmReject() {
            if(!this.rejectReason.trim()) {
                alert('请输入驳回原因');
                return;
            }

            const summary = this.summaries.find(item => item.id === this.currentSummaryId);
            if(summary) {
                summary.status = 'rejected';
                alert('已驳回该总结，原因：' + this.rejectReason);
                this.showRejectModal = false;
            }
        }
    }
});
